#include "DarkKnight.h"
#include "EntityNames.h"

#include <iomanip>

//returns attack damage to deal
int DarkKnight::Attack()
{
	//random number
	int random = rand()%10;

	if((random % 3) == 0)
	{
		SpecialTaunt();
		cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Dark) << " is using Special Attack..." << endl;
		//do special
		return ((int)(attack * 1.7));
	}
	else
	{
		Taunt();
		//do normal attack
		return attack;
	}
	
}

//determines how much damage is recieved from attack
//returns true if enemy has been killed
bool DarkKnight::Damage(int x)
{
	int damage;

	//calculate damage
	if(x <= defense)
	{
		damage = rand()%5;
	}
	else
	{
		damage = (x - defense) + rand()%5;
	}
	//calculate hp after damage deduction
	hp -= damage;

	cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Dark) << " has taken " << damage << " points of damage" << endl;

	//check to see if enemy is still alive
	if(hp > 0)
	{
		return false;
	}
	else if (hp <= 0)
	{
		DeathCry();
		//make sure hp is not negative
		hp = 0;
		return true;
	}
}

//create enemy taunt
void DarkKnight::Taunt()
{
	//random number
	int random = rand()%4;
	
	if(random == 0)
	{
		cout << "\n" << GetNameOfEntity(ent_Dark) << ": Die quickly!" << endl;
	}
	else if (random == 1)
	{
		cout << "\n" << GetNameOfEntity(ent_Dark) << ": I'll enjoy watching you suffer!" << endl;
	}
	else if (random == 2)
	{
		cout << "\n" << GetNameOfEntity(ent_Dark) << ": It's too late too run now" << endl;
	}
	else if (random == 3)
	{
		cout << "\n" << GetNameOfEntity(ent_Dark) << ": Killing you will be most satisfying" << endl;
	}
}

//create taunt for special attack
void DarkKnight::SpecialTaunt()
{
	cout << "\n" << GetNameOfEntity(ent_Dark) << ": DIE! DIE! DIE!" << endl;
}

//create enemy death cry
void DarkKnight::DeathCry()
{
	cout << "\n" << GetNameOfEntity(ent_Dark) << ": This can't be..\n" << setw(13) << left << " " 
		<<  "How could I lose???" << endl;
}